<?php
namespace app\service;
use think\facade\Db;

class appletRoomService{
	public function community(){
		//return Db::table("room")->where("community_name","香悦郡国际公寓")->distinct("community_name")->column("community_name");
		return Db::table("community")->where("id",42)->select();
		return Db::table("room")->distinct("community_name")->column("community_name");
	}
	public function disgroup($community_id){

		return Db::table("roominfo")->where("community_id",$community_id)->distinct("zz_group")->column("zz_group");
	}
	public function disbuild($community_id,$group){
		return Db::table("roominfo")->where("community_id",$community_id)->where("zz_group",$group)->distinct("building")->column("building");
	}
	public function disunit($community_id,$group,$building){
		return Db::table("roominfo")->where("community_id",$community_id)->where("zz_group",$group)->where("building",$building)->distinct("unit")->column("unit");
	}
	public function disroom($community_id,$group,$building,$unit){
		return Db::table("roominfo")->where("community_id",$community_id)->where("zz_group",$group)->where("building",$building)->where("unit",$unit)->distinct("room")->column("room");
	}

	//模糊查询小区
    public function communityNameAll($communityName)
    {
    	$list= Db::name('community')
    			->where('community_name',"like","$communityName%")
    			->select();
        
        return $list;
    }
    //小区列表
    public function communityListAll()
    {
    	
    	$list= Db::name('community')
    			
    			->select();
        return $list;
    }
	//模糊查询小区
    public function communityName($communityName,$serviceid)
    {
    	$propertylist=Db::name('property')->where('service_id',$serviceid)->column('id');
    	$list= Db::name('community')
    			->where('property_id','in',$propertylist)
    			->where('community_name',"like","$communityName%")
    			->select();
        
        return $list;
    }

    //小区列表
    public function communityList($serviceid)
    {
    	$propertylist=Db::name('property')->where('service_id',$serviceid)->column('id');
    	$list= Db::name('community')
    			->where('property_id','in',$propertylist)
    			->select();
        return $list;
    }

    //模糊查询小区
    public function communityInName($communityName,$serviceid)
    {
        $propertylist=Db::name('property')->where('service_id',"in",$serviceid)->column('id');
        $list= Db::name('community')
                ->where('property_id','in',$propertylist)
                ->where('community_name',"like","$communityName%")
                ->select();
        
        return $list;
    }

    //小区列表
    public function communityInList($serviceid)
    {
        $propertylist=Db::name('property')->where('service_id',"in",$serviceid)->column('id');
        $list= Db::name('community')
                ->where('property_id','in',$propertylist)
                ->select();
        return $list;
    }
}